session页面增加状态显示

chengzhenyu 8 年之前
父節點
當前提交
bbe7910209

+ 3 - 3
app/src/main/java/ai/pai/lensman/main/QueryBoxStatusInteractor.java

@@ -40,7 +40,7 @@ public class QueryBoxStatusInteractor  implements BaseInteractor{
40 40
     private void queryBoxStatus(){
41 41
         queryBoxTask = new HttpPostTask(null){
42 42
 
43
-            String boxStatusNum;
43
+            int boxStatusNum;
44 44
             String boxStatusMsg;
45 45
             String boxNo;
46 46
             @Override
@@ -53,7 +53,7 @@ public class QueryBoxStatusInteractor  implements BaseInteractor{
53 53
                         boxNo = data.getString("no.");
54 54
                         JSONObject boxStatus = data.getJSONObject("status");
55 55
                         boxStatusMsg = boxStatus.getString("msg");
56
-                        boxStatusNum = boxStatus.getString("code");
56
+                        boxStatusNum = boxStatus.getInt("code");
57 57
                         return true;
58 58
                     }
59 59
                 }catch (Exception e){
@@ -95,6 +95,6 @@ public class QueryBoxStatusInteractor  implements BaseInteractor{
95 95
 
96 96
     public interface BoxStatusListener{
97 97
 
98
-        void onBoxStatusFetched(String boxNo, String boxStatus, String boxStatusCode);
98
+        void onBoxStatusFetched(String boxNo, String boxStatus, int boxStatusCode);
99 99
     }
100 100
 }

+ 30 - 3
app/src/main/java/ai/pai/lensman/session/SessionActivity.java

@@ -31,6 +31,12 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
31 31
     @BindView(R.id.title_bar_middle_txt) TextView titleTextView;
32 32
     @BindView(R.id.recycler_view_photos) RecyclerView photosRecyclerView;
33 33
     @BindView(R.id.iv_scan)           ImageView qrcodeScanBtn;
34
+    @BindView(R.id.layout_device_status) View deviceConnectLayout;
35
+    @BindView(R.id.iv_box)              ImageView boxIndicator;
36
+    @BindView(R.id.iv_box_phone_line)   ImageView boxPhoneLineIndicator;
37
+    @BindView(R.id.iv_camera)           ImageView cameraIndicator;
38
+    @BindView(R.id.iv_camera_box_line)  ImageView cameraBoxLineIndicator;
39
+    @BindView(R.id.iv_phone)            ImageView phoneIndicator;
34 40
     private PhotoRecyclerAdapter adapter;
35 41
     private  SessionBean sessionBean;
36 42
     private SessionContract.Presenter presenter;
@@ -148,13 +154,34 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
148 154
     }
149 155
 
150 156
     @Override
151
-    public void showBoxDisconnectedView() {
152
-        Toast.makeText(this,NetworkUtil.isWifiConnected(this) ? R.string.box_status_error : R.string.network_disconnect,Toast.LENGTH_SHORT).show();
157
+    public void showBoxDisconnectedView(int errorCode,String errorMsg) {
158
+        deviceConnectLayout.setVisibility(View.VISIBLE);
159
+        boxIndicator.setImageResource(R.drawable.box_ok);
160
+        boxPhoneLineIndicator.setImageResource(R.drawable.link_ok);
161
+        cameraBoxLineIndicator.setImageResource(R.drawable.link_ok);
162
+        cameraIndicator.setImageResource(R.drawable.camera_ok);
163
+        phoneIndicator.setImageResource(R.drawable.network_ok);
164
+        switch (errorCode){
165
+            case 201:
166
+            case 202:
167
+            case 203:
168
+                boxIndicator.setImageResource(R.drawable.box_error);
169
+                break;
170
+            case 101:
171
+                cameraBoxLineIndicator.setImageResource(R.drawable.link_error);
172
+                break;
173
+        }
174
+        if(!NetworkUtil.isWifiConnected(this)){
175
+            boxPhoneLineIndicator.setImageResource(R.drawable.link_error);
176
+            phoneIndicator.setImageResource(R.drawable.network_error);
177
+        }
178
+        Toast.makeText(this,NetworkUtil.isWifiConnected(this) ? errorMsg :
179
+                getString(R.string.network_disconnect),Toast.LENGTH_SHORT).show();
153 180
     }
154 181
 
155 182
     @Override
156 183
     public void showBoxConnectedView() {
157
-
184
+        deviceConnectLayout.setVisibility(View.GONE);
158 185
     }
159 186
 
160 187
     @Override

+ 1 - 1
app/src/main/java/ai/pai/lensman/session/SessionContract.java

@@ -14,7 +14,7 @@ public class SessionContract {
14 14
         void showPhotoRecyclerView();
15 15
         void showEmptyView();
16 16
         void showToast(String toast);
17
-        void showBoxDisconnectedView();
17
+        void showBoxDisconnectedView(int errorCode,String errorMsg);
18 18
         void showBoxConnectedView();
19 19
     }
20 20
 

+ 3 - 3
app/src/main/java/ai/pai/lensman/session/SessionPresenter.java

@@ -124,12 +124,12 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
124 124
     }
125 125
 
126 126
     @Override
127
-    public void onBoxStatusFetched(String boxNo, String boxStatus, String boxStatusCode) {
127
+    public void onBoxStatusFetched(String boxNo, String boxStatus, int boxStatusCode) {
128 128
         LogHelper.d(TAG,"onBoxStatusFetched 盒子当前状态 "+boxStatus+" code = "+boxStatusCode);
129
-        if("200".equals(boxStatusCode)){
129
+        if(boxStatusCode == 200){
130 130
             sessionView.showBoxConnectedView();
131 131
         }else{
132
-            sessionView.showBoxDisconnectedView();
132
+            sessionView.showBoxDisconnectedView(boxStatusCode,boxStatus);
133 133
         }
134 134
     }
135 135
 }

二進制
app/src/main/res/drawable-xhdpi/box_error.png


二進制
app/src/main/res/drawable-xhdpi/box_ok.png


二進制
app/src/main/res/drawable-xhdpi/camera_ok.png


二進制
app/src/main/res/drawable-xhdpi/link_error.png


二進制
app/src/main/res/drawable-xhdpi/link_ok.png


二進制
app/src/main/res/drawable-xhdpi/network_error.png


二進制
app/src/main/res/drawable-xhdpi/network_ok.png


+ 8 - 1
app/src/main/res/layout/activity_session.xml

@@ -76,10 +76,17 @@
76 76
         android:layout_height="match_parent"
77 77
         android:layout_below="@id/title_bar_with_back_btn">
78 78
 
79
+        <include
80
+            android:id="@+id/layout_device_status"
81
+            android:layout_height="60dp"
82
+            android:layout_width="match_parent"
83
+            layout="@layout/layout_connect_status"/>
84
+
79 85
         <android.support.v7.widget.RecyclerView
80 86
             android:id="@+id/recycler_view_photos"
81 87
             android:layout_width="match_parent"
82
-            android:layout_height="match_parent" />
88
+            android:layout_height="match_parent"
89
+            android:layout_below="@id/layout_device_status"/>
83 90
 
84 91
         <ImageButton
85 92
             android:id="@+id/btn_session_complete"

+ 48 - 0
app/src/main/res/layout/layout_connect_status.xml

@@ -0,0 +1,48 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:gravity="center">
6
+
7
+    <ImageView
8
+        android:id="@+id/iv_camera"
9
+        android:layout_width="32dp"
10
+        android:layout_height="32dp"
11
+        android:layout_centerVertical="true"
12
+        android:src="@drawable/camera_ok" />
13
+
14
+    <ImageView
15
+        android:id="@+id/iv_camera_box_line"
16
+        android:layout_width="100dp"
17
+        android:layout_height="wrap_content"
18
+        android:layout_margin="3dp"
19
+        android:layout_centerVertical="true"
20
+        android:layout_toRightOf="@+id/iv_camera"
21
+        android:src="@drawable/link_ok" />
22
+
23
+    <ImageView
24
+        android:id="@+id/iv_box"
25
+        android:layout_width="32dp"
26
+        android:layout_height="32dp"
27
+        android:layout_centerVertical="true"
28
+        android:layout_toRightOf="@+id/iv_camera_box_line"
29
+        android:src="@drawable/box_ok" />
30
+
31
+    <ImageView
32
+        android:id="@+id/iv_box_phone_line"
33
+        android:layout_width="100dp"
34
+        android:layout_height="wrap_content"
35
+        android:layout_margin="3dp"
36
+        android:layout_centerVertical="true"
37
+        android:layout_toRightOf="@+id/iv_box"
38
+        android:src="@drawable/link_ok" />
39
+
40
+    <ImageView
41
+        android:id="@+id/iv_phone"
42
+        android:layout_width="32dp"
43
+        android:layout_height="32dp"
44
+        android:layout_centerVertical="true"
45
+        android:layout_toRightOf="@+id/iv_box_phone_line"
46
+        android:src="@drawable/network_ok" />
47
+
48
+</RelativeLayout>

+ 1 - 1
app/src/main/res/values/strings.xml

@@ -158,5 +158,5 @@
158 158
 
159 159
     <string name="set_price_fail">价格设置失败,请重试</string>
160 160
 
161
-    <string name="box_status_error">盒子状态错误,请检查或直接重启盒子</string>
161
+    <string name="box_status_error">盒子状态错误,请检查</string>
162 162
 </resources>